package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment;
import com.google.gwt.i18n.client.HasDirection.Direction;
import com.google.gwt.user.client.ui.TextBoxBase;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class ImageViewer implements EntryPoint {
	
	private Button btnIngresar = new Button("Ingresar");
	TextBox textCoo1 = new TextBox();
	TextBox textCoo2 = new TextBox();
	TextBox textCoo3 = new TextBox();

	public void onModuleLoad() {
		
		RootPanel rootPanel = RootPanel.get();
		
		Grid grid = new Grid(2, 3);
		rootPanel.add(grid, 81, 64);
		grid.setSize("285px", "132px");
		
		textCoo1.setMaxLength(2);
		textCoo1.setTextAlignment(TextBoxBase.ALIGN_CENTER);
		textCoo1.setAlignment(TextAlignment.CENTER);
		grid.setWidget(0, 0, textCoo1);
		textCoo1.setSize("60px", "58px");
		
		textCoo2.setMaxLength(2);
		textCoo2.setTextAlignment(TextBoxBase.ALIGN_CENTER);
		textCoo2.setAlignment(TextAlignment.CENTER);
		grid.setWidget(0, 1, textCoo2);
		textCoo2.setSize("60px", "58px");
		
		textCoo3.setMaxLength(2);
		textCoo3.setTextAlignment(TextBoxBase.ALIGN_CENTER);
		textCoo3.setAlignment(TextAlignment.CENTER);
		grid.setWidget(0, 2, textCoo3);
		textCoo3.setSize("60px", "58px");
		
		Label lblC1 = new Label("C1");
		lblC1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		grid.setWidget(1, 0, lblC1);
		lblC1.setSize("60", "58\r\n");
		
		Label lblC2 = new Label("C2");
		lblC2.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		grid.setWidget(1, 1, lblC2);
		lblC2.setSize("60", "58");
		
		Label lblC3 = new Label("C3");
		lblC3.setDirectionEstimator(true);
		lblC3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		grid.setWidget(1, 2, lblC3);
		grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_MIDDLE);
		
		Label lblIngreseCoordenadas = new Label("Ingrese Coordenadas");
		rootPanel.add(lblIngreseCoordenadas, 139, 27);
		lblIngreseCoordenadas.setSize("180px", "31px");
		
		Grid grid_1 = new Grid(1, 1);
		rootPanel.add(grid_1, 191, 200);
		grid_1.setSize("68px", "46px");
		grid_1.setWidget(0, 0, btnIngresar);
		
		
		
		btnIngresar.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				actionIngresar();
			}
		});
		
	}
	
	private void actionIngresar() {
		SOAService.Util.getInstance().validarCoordenada(textCoo1.getText(), textCoo2.getText(), textCoo3.getText(), new AsyncCallback<String>(){
			public void onSuccess(String result) {
				// TODO Auto-generated method stub
        		
        		//persona.add(textBoxNombre, textRUN_DV, textRunCuerpo);
        		
        		Window.confirm(result);
				
			}
            public void onFailure(Throwable caught) {
            	
            }	
		});    
    }
}
